<template>
	<custom-page>
	<view>
		<u-image :src="detail.image" height="360" width="100%" v-if="detail.image!=''"></u-image>
		<view class="titleStyle">{{detail.title}}</view>
		
		<view class="subheadStlyle">{{detail.Subtitle}}</view>
		<view style="margin-top: 20px;" v-html="detail.content">
			
		</view>
	</view>
	</custom-page>
</template>

<script>
	import Api from '@/util/api.js'
	export default {
		data() {
			return {
				detail:{}
			};
		},
		onLoad(e) {
			var that = this
			console.log('我进来了',e)
			if('type' in e){
				
				switch (e.type) {
					case 'message':
					that.MessageDetail(e.id)
						break;
					case 'near':
					that.getSurroundDetail(e.id)
					console.log('输出')
					uni.setNavigationBarTitle({
						　　title:'周边详情'
						})
						break;
					case 'news':
					that.getNewsDetail(e.id)
					console.log('输出我是新闻')
					uni.setNavigationBarTitle({
						　　title:'新闻详情'
						})
						break;
					default:
						break;
				}
				
			}
			
		},
		methods:{
			// 获取通知详情
			MessageDetail(id){
				var that = this
				var data = {
					id:id
				}
				Api.MessageDetail(data).then(res=>{
					console.log('获取成功',res)
					that.detail = res.data
				})
			},
			// 获取周边详情
			getSurroundDetail(id){
				var that = this
				var data = {
					id:id
				}
				Api.getSurroundDetail(data).then(res=>{
					console.log('获取成功',res)
					that.detail = res.data
				})
			},
			//获取新闻详情
			getNewsDetail(id){
				var that = this
				var data = {
					id:id
				}
				Api.getNewsDetail(data).then(res=>{
					console.log('获取成功',res)
					that.detail = res.data
				})
			}
		}
	}
</script>

<style lang="scss">
	
	.titleStyle{
		margin-top: 20px;
		font-size: 20px;
		text-align: center;
		
	}
	.subheadStlyle{
		margin-top: 15px;
		text-indent: 15px;
		font-size: 15px;
	}

</style>
